package models;

import javax.persistence.Entity;
import javax.persistence.OneToOne;

import play.data.validation.Required;
import play.db.jpa.Model;


 /** 
 * 
 * 
 * This Model represents the ternary relation between the User, Organization, and Role.
 * It is defined as OneToOne relation between each as every instance of this model has 
 * one User assigned to one Organization with one Role.
 * @author Heba
 */
@Entity
public class HasRoleInOrganization extends Model {
	@Required
	@OneToOne
	public User user;
	@Required
	@OneToOne
	public Role role;
	@Required
	@OneToOne
	public Organization organization;

	/**
	 * 
	 * The constructor that takes a User, a Role, and an Organization.
	 * @param user User instance
	 * @param role Role instance
	 * @param org Organization instance
	 * @author heba
	*/
	public HasRoleInOrganization(User user, Role role, Organization org) {
		this.user = user;
		this.role = role;
		this.organization = org;
	}

}
